package cn.autumnorange.entity;

import cn.autumnorange.enums.DeliveryStatusEnum;
import cn.autumnorange.enums.OrderStatusEnum;
import cn.autumnorange.enums.PostageStatusEnum;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.UpdateTimestamp;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;

/**
 * @ClassName OrderEntity
 * @Description
 * @Date 2019/4/11 12:18
 * @Version 1.0
 */
@Entity
@DynamicUpdate
@Table(name = "order_master")
public class OrderEntity implements Serializable {

    /** 订单id */
    private String orderId;

    /** 商品名称 */
    private String productName;

    /** 买家姓名 */
    private String buyerName;

    /** 买家地址 */
    private String buyerAddress;

    /** 买家手机号码 */
    private String buyerPhone;

    /** 快递单号 */
    private String courierNumber;

    /** 订单状态, 默认为0等待审核. */
    private Integer orderStatus = OrderStatusEnum.WAIT.getCode();

    /** 付款方式, 默认为0货到付款. */
    private Integer postageStatus = PostageStatusEnum.CASH_ON_DELIVERY.getCode();

    /** 发货状态, 默认为0未发货. */
    private Integer deliveryStatus = DeliveryStatusEnum.UNSHIPPED.getCode();

    /** 创建时间. */
    private Date createTime;

    /** 更新时间. */
    private Date updateTime;

    @Id
    @Column(name = "orderId", length = 32)
    public String getOrderId() {
        return orderId;
    }

    public void setOrderId(String orderId) {
        this.orderId = orderId;
    }

    @Column(name = "productName")
    public String getProductName() {
        return productName;
    }

    public void setProductName(String productName) {
        this.productName = productName;
    }

    @Column(name = "buyerName")
    public String getBuyerName() {
        return buyerName;
    }

    public void setBuyerName(String buyerName) {
        this.buyerName = buyerName;
    }

    @Column(name = "buyerAddress")
    public String getBuyerAddress() {
        return buyerAddress;
    }

    public void setBuyerAddress(String buyerAddress) {
        this.buyerAddress = buyerAddress;
    }

    @Column(name = "buyerPhone")
    public String getBuyerPhone() {
        return buyerPhone;
    }

    public void setBuyerPhone(String buyerPhone) {
        this.buyerPhone = buyerPhone;
    }

    @Column(name = "courierNumber")
    public String getCourierNumber() {
        return courierNumber;
    }

    public void setCourierNumber(String courierNumber) {
        this.courierNumber = courierNumber;
    }

    @Column(name = "orderStatus")
    public Integer getOrderStatus() {
        return orderStatus;
    }

    public void setOrderStatus(Integer orderStatus) {
        this.orderStatus = orderStatus;
    }

    @Column(name = "postageStatus")
    public Integer getPostageStatus() {
        return postageStatus;
    }

    public void setPostageStatus(Integer postageStatus) {
        this.postageStatus = postageStatus;
    }

    @Column(name = "deliveryStatus")
    public Integer getDeliveryStatus() {
        return deliveryStatus;
    }

    public void setDeliveryStatus(Integer deliveryStatus) {
        this.deliveryStatus = deliveryStatus;
    }

    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "createTime", updatable = false)
    @CreationTimestamp
    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    @Column(name = "updateTime")
    @UpdateTimestamp
    @Temporal(TemporalType.TIMESTAMP)
    public Date getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }
}
